home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / MFC / src / bardlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  4.0 KB  |  162 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. #include "stdafx.h"
  12. #if !defined(_WIN32_WCE_NO_CONTROLBARS)
  13. #include "occimpl.h"
  14.  
  15. #ifdef AFX_CORE3_SEG
  16. #pragma code_seg(AFX_CORE3_SEG)
  17. #endif
  18.  
  19. #ifdef _DEBUG
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23.  
  24. #define new DEBUG_NEW
  25.  
  26. CDialogBar::CDialogBar()
  27. {
  28. #ifndef _AFX_NO_OCC_SUPPORT
  29.     m_lpszTemplateName = NULL;
  30.     m_pOccDialogInfo = NULL;
  31. #endif
  32. }
  33.  
  34. CDialogBar::~CDialogBar()
  35. {
  36.     DestroyWindow();    // avoid PostNcDestroy problems
  37. }
  38.  
  39. BOOL CDialogBar::Create(CWnd* pParentWnd, LPCTSTR lpszTemplateName,
  40.     UINT nStyle, UINT nID)
  41. {
  42.     ASSERT(pParentWnd != NULL);
  43.     ASSERT(lpszTemplateName != NULL);
  44.  
  45. #ifdef _DEBUG
  46.     // dialog template must exist and be invisible with WS_CHILD set
  47.     if (!_AfxCheckDialogTemplate(lpszTemplateName, TRUE))
  48.     {
  49.         ASSERT(FALSE);          // invalid dialog template name
  50.         PostNcDestroy();        // cleanup if Create fails too soon
  51.         return FALSE;
  52.     }
  53. #endif //_DEBUG
  54.  
  55.     // allow chance to modify styles
  56.     m_dwStyle = (nStyle & CBRS_ALL);
  57.     CREATESTRUCT cs;
  58.     memset(&cs, 0, sizeof(cs));
  59.     cs.lpszClass = _afxWndControlBar;
  60.     cs.style = (DWORD)nStyle | WS_CHILD;
  61.     cs.hMenu = (HMENU)nID;
  62.     cs.hInstance = AfxGetInstanceHandle();
  63.     cs.hwndParent = pParentWnd->GetSafeHwnd();
  64.     if (!PreCreateWindow(cs))
  65.         return FALSE;
  66.  
  67.     // create a modeless dialog
  68.  
  69. #ifndef _AFX_NO_OCC_SUPPORT
  70.     m_lpszTemplateName = lpszTemplateName;
  71. #endif
  72.  
  73.     // initialize common controls
  74.     VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTLS_REG));
  75.     AfxDeferRegisterClass(AFX_WNDCOMMCTLSNEW_REG);
  76.  
  77.     BOOL bSuccess = CreateDlg(lpszTemplateName, pParentWnd);
  78.  
  79. #ifndef _AFX_NO_OCC_SUPPORT
  80.     m_lpszTemplateName = NULL;
  81. #endif
  82.  
  83.     if (!bSuccess)
  84.         return FALSE;
  85.  
  86.     // dialog template MUST specify that the dialog
  87.     //  is an invisible child window
  88.     SetDlgCtrlID(nID);
  89.     CRect rect;
  90.     GetWindowRect(&rect);
  91.     m_sizeDefault = rect.Size();    // set fixed size
  92.  
  93.     // force WS_CLIPSIBLINGS
  94.     ModifyStyle(0, WS_CLIPSIBLINGS);
  95.  
  96.     if (!ExecuteDlgInit(lpszTemplateName))
  97.         return FALSE;
  98.  
  99.     // force the size to zero - resizing bar will occur later
  100.     SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_SHOWWINDOW);
  101.  
  102.     return TRUE;
  103. }
  104.  
  105. CSize CDialogBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz)
  106. {
  107.     if (bStretch) // if not docked stretch to fit
  108.         return CSize(bHorz ? 32767 : m_sizeDefault.cx,
  109.             bHorz ? m_sizeDefault.cy : 32767);
  110.     else
  111.         return m_sizeDefault;
  112. }
  113.  
  114. void CDialogBar::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler)
  115. {
  116.     UpdateDialogControls(pTarget, bDisableIfNoHndler);
  117. }
  118.  
  119. #ifndef _AFX_NO_OCC_SUPPORT
  120.  
  121. //{{AFX_MSG_MAP(CDialogBar)
  122. BEGIN_MESSAGE_MAP(CDialogBar, CControlBar)
  123.     ON_MESSAGE(WM_INITDIALOG, HandleInitDialog)
  124. END_MESSAGE_MAP()
  125. //}}AFX_MSG_MAP
  126.  
  127. LRESULT CDialogBar::HandleInitDialog(WPARAM, LPARAM)
  128. {
  129.     Default();  // allow default to initialize first (common dialogs/etc)
  130.  
  131.     // create OLE controls
  132.     COccManager* pOccManager = afxOccManager;
  133.     if ((pOccManager != NULL) && (m_pOccDialogInfo != NULL))
  134.     {
  135.         if (!pOccManager->CreateDlgControls(this, m_lpszTemplateName,
  136.             m_pOccDialogInfo))
  137.         {
  138.             TRACE0("Warning: CreateDlgControls failed during dialog bar init.\n");
  139.             return FALSE;
  140.         }
  141.     }
  142.  
  143.     return TRUE;
  144. }
  145.  
  146. BOOL CDialogBar::SetOccDialogInfo(_AFX_OCC_DIALOG_INFO* pOccDialogInfo)
  147. {
  148.     m_pOccDialogInfo = pOccDialogInfo;
  149.     return TRUE;
  150. }
  151.  
  152. #endif //!_AFX_NO_OCC_SUPPORT
  153.  
  154. #ifdef AFX_INIT_SEG
  155. #pragma code_seg(AFX_INIT_SEG)
  156. #endif
  157.  
  158. IMPLEMENT_DYNAMIC(CDialogBar, CControlBar)
  159.  
  160. ///////////////////////////////////////////////////////////////////////////
  161. #endif // _WIN32_WCE_NO_CONTROLBARS
  162.